package org.engere.server;

import java.net.*;
import java.io.*;

import org.jfarrell.classes.PointImage;

public class Server
{
	private ServerSocket server;
	private Socket socket;
	private ObjectInputStream in;
	
	public Server(int port)
	{
		try
		{
			server = new ServerSocket(port);
			System.out.println( "Accepting Connections" );
			socket = server.accept();
			in = new ObjectInputStream(socket.getInputStream());
			PointImage pi = (PointImage) in.readObject();
			
			//Start coding here
		}
		catch(IOException io)
		{
			io.printStackTrace();
			System.out.println("I/O Error in Server.Server()");
		}
		catch(ClassNotFoundException cnf)
		{
			cnf.printStackTrace();
			System.out.println("Error of some sort.  Probably with in.readObject");
		}
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		if (args.length != 1)
		{
			System.out.println( "Syntax Error: java Server <listening port>" );
			System.exit( 0 );
		}
		new Server( Integer.parseInt(args[0]) );
	}

}
